<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="renderer" content="webkit">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>#(login_app_name)</title>
		<link rel="stylesheet" type="text/css" href="/static/admin/layui/css/layui.css"/>
		<link rel="stylesheet" type="text/css" href="/static/admin/css/admin.css"/>
	</head>
	<body>
		<div class="main-layout" id='main-layout'>
			<!--侧边栏-->
			<div class="main-layout-side">
				<div class="m-logo">
					<div style="line-height: 60px;width:100%; text-align: center; font-size: 22px; font-weight: bold; color:#fff;">#(login_app_name)</div>
				</div>
				<ul class="layui-nav layui-nav-tree" lay-filter="leftNav">
				  #(listmenuhtml)
				</ul>
			</div>
			<!--右侧内容-->
			<div class="main-layout-container">
				<!--头部-->
				<div class="main-layout-header">
					<div class="menu-btn" id="hideBtn">
						<a href="javascript:;">
							<span class="iconfont">&#xe60e;</span>
						</a>
					</div>
					<div class="menu-btn" id="hideBtn" style="width:200px; text-align: left;">
						<span id="top_org_name" style="font-size: 20px; color:#f8bb74; font-weight:bold;">#(index_org_name??)</span>
					</div>
					<ul class="layui-nav" lay-filter="rightNav">
					  <li class="layui-nav-item">
					    <a href="javascript:;" data-url="/admin/list/myinfo" data-id='#(login_user_id)' data-text="个人信息" title="点击编辑资料">#(login_user_name)</a>
					  </li>
					  <li class="layui-nav-item"><a id="btn_logout" href="javascript:;">退出</a></li>
					</ul>
				</div>
				<!--主体内容-->
				<div class="main-layout-body">
					<!--tab 切换-->
					<div class="layui-tab layui-tab-brief main-layout-tab" lay-filter="tab" lay-allowClose="true">
					  <ul class="layui-tab-title">
					    <li class="layui-this welcome">后台主页</li>
					  </ul>
					  <div class="layui-tab-content">
					    <div class="layui-tab-item layui-show" style="background: #f5f5f5;">
					    	<!--1-->
					    	<iframe src="#(attr_welcome_url)" width="100%" height="100%" name="iframe" scrolling="auto" class="iframe" framborder="0"></iframe>
					    	<!--1end-->
					    </div>
					  </div>
					</div>
				</div>
			</div>
			<!--遮罩-->
			<div class="main-mask">
				
			</div>
		</div>
	<script src="/static/js/jquery-3.4.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/admin/js/jsutil.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/admin/js/common.js" type="text/javascript" charset="utf-8"></script>
		<script src="/static/admin/js/main.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			function goLoginPage(){
				layerMsg("您还没有登录！请点击[确定]，先登录！", function(){
					window.location.href = "/admin/login/" + getUrlParam('app_id');
				});
			}
			
			layui.use(['element', 'layer', 'form'], function(){
				var laypage = layui.laypage
				,layer = layui.layer;
				var element = layui.element();
				
				$('#btn_logout').click(function(){
					sendPost("/api/auth/logout", null, function(res){
							//console.log(res);
							layer.alert(res.msg, {
								title: '信息提示'
							}, function(idx){
								if (res.code==202){
									window.location.href='/admin/login/#(login_app_id)';
								}
							});
					});
				});
				
				function initLeftMenu(listmenu, pid, level){
					var shtml = "";
					//筛选
					var listp = listmenu.filter(function (e) { return e.parent_id == pid; });
					//遍历结果对象
					for (var i = 0; i < listp.length; i++) {
						shtml += '<li class="layui-nav-item">';
						shtml += '<a href="javascript:;"><i class="iconfont">'+listp[i].icon_code+'</i>'+listp[i].menu_name+'</a>';
						var listc = listmenu.filter(function (e) { return e.parent_id == listp[i].menu_id; });
						if (listc != null && listc != 'undefined' && listc.length > 0){
							shtml += '<dl class="layui-nav-child">';
							shtml += '';
							for(var j= 0; j < listc.length; j++){
								shtml += '<dd><a href="javascript:;" data-url="'+listc[j].menu_url
								+'" data-id='+listc[j].menu_id+' data-text="'
								+listc[j].menu_name+'"><span class="l-line"></span>'
								+listc[j].menu_name+'</a></dd>';
							}
							shtml += '</dl>';
						}
						
						shtml += '</li>';
					}
					$('ul[lay-filter="leftNav"]').html(shtml);
				}
				
				function page_init(){
					sendPost("/api/permission/getMyMenu", null, function(res){
							//console.log(res);
							if (res.hasOwnProperty("listmenu")) {
								initLeftMenu(res.listmenu, 0, 0);
							}
					});
				}
				
				//page_init();
			});
		</script>
	</body>
</html>
